let option = {
    title: {
      text: 'Stacked Line',
    },
    tooltip: {
      trigger: 'axis',
    },
    legend: {
      data: [],
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true,
    },
    toolbox: {
      feature: {
        saveAsImage: {},
      },
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: [],
    },
    yAxis: {
      type: 'value',
    },
    series: [],
    dataZoom: [
      {
        type: 'inside',
        xAxisIndex: 0,
        start: 0,
        end: 100,
      },
      {
        type: 'slider',
        xAxisIndex: 0,
        start: 0,
        end: 100,
      },
    ],
  };


  export default function makeOption(csvData) {
    const names = new Set();
        let table = ""
        csvData.data.forEach((item) => {
          names.add(item._field);
          // console.log("item._field");
  
          option.xAxis.data.push(item._time);
          if (table != item.table) {
            option.series.push({
              name: item._field,
              type: 'line',
              stack: 'Total',
              data: [item._value],
            });
          } else if (option.series[option.series.length - 1].data != null) {
              option.series[option.series.length - 1].data.push(item._value);
          }
          table = item.table;
        });

        option.xAxis.data = [...new Set(option.xAxis.data)]
        
        for (const name of names.keys()) {
          // console.log(name);
          option.legend.data.push(name);
        }
        return option;
  }